package com.efast.dmom.mes.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.dmom.mes.bean.EquipRepairInfo;
import com.efast.dmom.mes.bean.ResultBean;
import com.efast.dmom.mes.entity.base.IModificationFlags;
import com.efast.dmom.mes.service.EquipRepairInfoService;

@Controller
@RequestMapping("/equipRepairInfo")
public class EquipRepairInfoController {
	
	@Autowired
	private EquipRepairInfoService equipRepairInfoService;
	
	@RequestMapping(value = "/operateByEquipRepairInfo")
	public @ResponseBody ResultBean operateByEquipRepairInfo(@RequestBody EquipRepairInfo equipRepairInfo) {
		// Determine the new
		if ( equipRepairInfo.getModificationFlag() == IModificationFlags.NEW) {
			return equipRepairInfoService.save(equipRepairInfo);
			// Judge update
		} else if (equipRepairInfo.getModificationFlag() == IModificationFlags.MODIFIED) {
			return equipRepairInfoService.update(equipRepairInfo);
			// Judge to delete
		} else if (equipRepairInfo.getModificationFlag() == IModificationFlags.DELETED) {
			return equipRepairInfoService.delete(equipRepairInfo);
		}
		return null;
	}

}
